package com.Policing.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.Policing.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/1/21.
 */

public class Reception_Adapter extends BaseAdapter {
    private List<Map<String, Object>> data;
    private LayoutInflater layoutInflater;
    private Context context;
    public Reception_Adapter(Context context, List<Map<String, Object>> data) {
        //传入的data，就是我们要在listview中显示的信息
        this.context = context;
        this.data = data;
        this.layoutInflater = LayoutInflater.from(context);
    }
    public class Info {
        public TextView assetNumber;//资产编码
        public TextView assetName;//资产名称
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        Info info = new Info();
        convertView = layoutInflater.inflate(R.layout.reception_list, null);
        info.assetNumber = (TextView) convertView
                .findViewById(R.id.assetNumber);
        info.assetName = (TextView) convertView
                .findViewById(R.id.assetName);
        //设置数据
        info.assetName.setText((String) data.get(position).get(
                "assetName"));
        info.assetNumber.setText((String) data.get(position).get(
                "assetNumber"));
        return convertView;
    }
}
